;
var template_upload = {
        init: function () {
            this.eventBind();
        },
        eventBind: function () {
            $(".do-upload").click(function () {
                    var btn_target = $(this);
                    if (btn_target.hasClass("disabled")) {
                        common_ops.alert("正在处理！！请不要重复点击~~");
                        return;
                    }

                    var formData = new FormData();
                    // var f = document.getElementById('upload_input').files[0];
                    var classone = $("select[name=classone]").val();
                    var uid = $("input[name=uid]").val();


                    var files = $("#input input[type='file']");
                    for (var i = 0; i < files[0].files.length; i++) {
                        formData.append("files", files[0].files[i]);
                    }

                    formData.append("classone", classone);
                    formData.append("uid", uid);
                    $("#loadingModal").modal('show');

                    $.ajax({
                            url: common_ops.buildUrl("/template/upload"),
                            data: formData,
                            cache: false,
                            processData: false,
                            contentType: false,
                            type: 'POST',
                            success: function (res) {
                                $('#loadingModal').modal('hide');
                                window.location.href = common_ops.buildUrl("/template/template");

                            }
                        }
                    )


                }
            )
            ;
        }
    }
;

$(document).ready(function () {
    template_upload.init();
});